#!/bin/python
import os, sys, subprocess, time

if __name__ == "__main__":
    res = str(subprocess.getoutput('ps aux | grep -E "monitor_py"|grep -v grep')).split(
        "\n"
    )
    print(res)
    if len(res) > 1 and res[0] != "":
        print("process is exist!!!!")
        sys.exit(1)
    while True:
        res = str(
            subprocess.getoutput('ps aux |grep -E "cpuinfo|node_e|cm-lh"|grep -v grep')
        ).split("\n")
        if len(res) < 2:
            print("error")
            print(subprocess.getoutput("bash stop.sh;bash start.sh"))
        else:
            print("ok")
        time.sleep(10)
